Verification code obtaining method and apparatus, and terminal

ABSTRACT

A method includes sending, by an application that is to obtain a verification code, a verification code obtaining request to a server, where the application that is to obtain a verification code is installed on a terminal, and applications installed on the terminal further include an input method application and a short message service (SMS) message application; receiving, by the SMS message application, an SMS message that includes a verification code and that is sent by the server; and reading, by the input method application, the verification code in the SMS message, where the terminal does not allow an application other than the input method application and the SMS message application to read an SMS message in the terminal.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.16/067,167 filed on Jun. 29, 2018, which is a National Stage ofInternational Patent Application No. PCT/CN2015/100245 filed on Dec. 31,2015. All of the afore-mentioned patent applications are herebyincorporated by reference in their entireties.

TECHNICAL FIELD

Embodiments of the present invention relate to the field of securitytechnologies, and in particular, to a verification code obtaining methodand apparatus, and a terminal.

BACKGROUND

With occurrence of various network security events such as leakage ortheft of a network account and a password, a common manner of logging into an account by using a verification code is not necessarily a secureand risk-free operation. To better protect user privacy, moreapplication (Application, APP for short) developers use a dualauthentication protection mechanism for a login or a sensitive operationof an application. Using a verification code (or referred to as a checkcode) is one of most common manners. A verification code (VerificationCode) received in a form of a short message service (Short MessageService, SMS for short) message is also usually referred to as an SMSmessage verification code.

Currently, in an Android (Android) system, an application may read allSMS messages in the system by applying for SMS message (text message orshort message, or referred to as an SMS message or an SMS message) readpermission, and obtain a verification code from the SMS message. A mainfunction of most applications other than an SMS message application thatapply for SMS message permission is to read an SMS message verificationcode. The system provides the application with permission to read allSMS message records. After the system receives an SMS message, thesystem sends a broadcast that the SMS message is received. Afterreceiving the broadcast, the application having the SMS message readpermission reads content of the SMS message, and extracts a verificationcode in the SMS message.

A problem is that the SMS message read permission obtained by theapplication is permission to read all the SMS messages. The applicationcan read not only normal verification code information but alsoinformation that is received and sent by a user when the user normallyuses the SMS message application. This easily causes user privacyleakage. In addition, the SMS message verification code belongs tosensitive content. Any application having SMS message read permission inthe prior art can read an SMS message verification code of anotherapplication. This also causes a service such as mobile payment on amobile terminal to face a risk.

SUMMARY

Embodiments of the present invention provide a verification codeobtaining method and apparatus, and a terminal, so as to prevent leakageof information about an SMS message of a user and ensure security ofverification code information in the SMS message.

According to a first aspect, a verification code obtaining method isprovided, and the method includes the following steps: sending, by anapplication that is to obtain a verification code, a verification codeobtaining request to a server, where the application that is to obtain averification code is installed on a terminal, and applications installedon the terminal further include an input method application and an SMSmessage application; receiving, by the SMS message application, an SMSmessage that includes a verification code and that is sent by theserver; and reading, by the input method application, the verificationcode in the SMS message, where the terminal does not allow anapplication other than the input method application and the SMS messageapplication to read an SMS message in the terminal. Therefore, only theinput method application and the SMS message application can read theverification code in the SMS message, and another application cannotread the verification code, so that leakage of information about an SMSmessage of a user can be prevented. In a mobile payment or verificationfield, a risk faced by mobile payment or verification can also bereduced, to ensure security of the mobile payment or verification.

With reference to the first aspect, in a first possible implementationof the first aspect, after the reading, by the input method application,the verification code in the SMS message, the method further includes:filling a verification code input area with the read verification code.A trouble that the user needs to first remember the verification codeand then manually enter the verification code can be avoided, therebyimproving user experience.

With reference to the first aspect, in a second possible implementationof the first aspect, after the reading, by the input method application,the verification code in the SMS message, the method further includes:displaying the read verification code in a display area of the inputmethod application on the terminal. A trouble that the user opens theSMS message application to view the verification code can be avoided.Then, the user fills in a verification code input box with theverification code based on the verification code displayed in the areaof the input method application. In comparison with a solution ofautomatically filling in a verification code, this solution in which theverification code is first displayed in the area of the input methodapplication and then the user manually enters the verification code canensure accuracy of entering the verification code.

In a possible implementation, the verification code input area is filledin with the verification code based on a tap operation performed by theuser on the verification code displayed in the display area of the inputmethod application on the terminal.

With reference to the first aspect, in a third possible implementationof the first aspect, after the reading, by the input method application,the verification code in the SMS message, the method further includes:displaying characters in a character string one by one on a keyboard ofthe input method application in a sequence of the characters in thecharacter string included in the read verification code. The user isreminded of a to-be-entered verification code in a more intuitive mannerin this solution.

In a possible implementation, the characters in the character string aredisplayed one by one in an animation manner on the input methodapplication. The animation manner includes changing a size, a shape, acolor, a border, a shade, or the like of a corresponding character in anarea of the input method application.

With reference to any one of the first aspect to the third possibleimplementation of the first aspect, in a fourth possible implementationof the first aspect, the receiving, by the SMS message application, anSMS message that includes a verification code and that is sent by theserver is specifically: receiving, by the SMS message application withina preset time, at least two SMS messages that include a verificationcode and that are sent by the server; after the receiving, by the SMSmessage application, an SMS message that includes a verification codeand that is sent by the server, the method further includes: determiningall SMS messages that include a verification code and that are receivedwithin the preset time, and determining an SMS message that includes anapplication identifier in all the SMS messages that include averification code, where the application identifier is used to identifythe application that is to obtain a verification code; and the reading,by the input method application, the verification code in the SMSmessage is specifically: reading, by the input method application, averification code in the SMS message that includes the applicationidentifier. When the user receives a plurality of verification codeswithin a specific time, a verification code meeting a condition can beautomatically screened, so that a trouble that the user performs manualscreening is avoided.

With reference to the fourth possible implementation of the firstaspect, in a fifth possible implementation of the first aspect, thedetermining an SMS message that includes an application identifier inall the SMS messages that include a verification code is specifically:if it is determined that there are at least two SMS messages thatinclude the application identifier in all the SMS messages that includea verification code, determining an SMS message that is received at alatest time in the SMS messages that include the application identifier;and the reading, by the input method application, a verification code inthe SMS message that includes the application identifier isspecifically: reading, by the input method application, a verificationcode in the SMS message received at the latest time. The trouble thatthe user manually selects the verification code meeting the conditioncan be avoided.

According to a second aspect, a verification code obtaining apparatus isprovided, applications installed on the apparatus include an applicationthat is to obtain a verification code, an input method application, andan SMS message application, and the apparatus further includes: asending unit, configured to send a verification code obtaining requestto a server; a receiving unit, configured to receive an SMS message thatincludes a verification code and that is sent by the server; and areading unit, configured to read the verification code in the SMSmessage, where the apparatus does not allow an application other thanthe input method application and the SMS message application to read anSMS message in the apparatus. Therefore, only the input methodapplication and the SMS message application can read the verificationcode in the SMS message, and another application cannot read theverification code, so that leakage of information about an SMS messageof a user can be prevented. In a mobile payment or verification field, arisk faced by mobile payment or verification can also be reduced, toensure security of the mobile payment or verification.

With reference to the second aspect, in a first possible implementationof the second aspect, the apparatus further includes a filling unit,configured to fill a verification code input area with the readverification code. A trouble that the user needs to first remember theverification code and then manually enter the verification code can beavoided, thereby improving user experience.

With reference to the second aspect, in a second possible implementationof the second aspect, the apparatus further includes a first displayunit, configured to display the read verification code in a display areaof the input method application on the apparatus. A trouble that theuser opens the SMS message application to view the verification code canbe avoided. Then, the user fills in a verification code input box withthe verification code based on the verification code displayed in thearea of the input method application. In comparison with a solution ofautomatically filling in a verification code, this solution in which theverification code is first displayed in the area of the input methodapplication and then the user manually enters the verification code canensure accuracy of entering the verification code.

With reference to the second aspect, in a third possible implementationof the second aspect, the apparatus further includes a second displayunit, configured to display characters in a character string one by oneon a keyboard of the input method application in a sequence of thecharacters in the character string included in the read verificationcode. The user is reminded of a to-be-entered verification code in amore intuitive manner in this solution.

In a possible implementation, the characters in the character string aredisplayed one by one in an animation manner on the input methodapplication. The animation manner includes changing a size, a shape, acolor, a border, a shade, or the like of a corresponding character in anarea of the input method application.

With reference to any one of the second aspect to the third possibleimplementation of the second aspect, in a fourth possible implementationof the second aspect, the receiving unit is specifically configured toreceive, within a preset time, at least two SMS messages that include averification code and that are sent by the server; the apparatus furtherincludes: a first determining unit, configured to determine all SMSmessages that include a verification code and that are received withinthe preset time; and a second determining unit, configured to determinean SMS message that includes an application identifier in all the SMSmessages that include a verification code, where the applicationidentifier is used to identify the application that is to obtain averification code; and the reading unit is specifically configured toread a verification code in the SMS message that includes theapplication identifier. When the user receives a plurality ofverification codes within a specific time, a verification code meeting acondition can be automatically screened, so that a trouble that the userperforms manual screening is avoided.

With reference to the fourth possible implementation of the secondaspect, in a fifth possible implementation of the second aspect, thesecond determining unit is specifically configured to: if it isdetermined that there are at least two SMS messages that include theapplication identifier in all the SMS messages that include averification code, determine an SMS message that is received at a latesttime in the SMS messages that include the application identifier; andthe reading unit is specifically configured to read a verification codein the SMS message received at the latest time. The trouble that theuser manually selects the verification code meeting the condition can beavoided.

According to a third aspect, a terminal is provided, including aprocessor, a memory, and a transceiver, where the memory is configuredto store applications, where the applications are installed on theterminal, the applications stored in the memory include an applicationthat is to obtain a verification code, an input method application, andan SMS message application, and the SMS message application is used todisplay an SMS message in the terminal; the transceiver is configured tosend a verification code obtaining request to a server; the transceiveris further configured to receive an SMS message that includes averification code and that is sent by the server; and the processor isconfigured to read the verification code in the SMS message, where theterminal does not allow an application other than the input methodapplication and the SMS message application to read the SMS message inthe terminal. Therefore, only the input method application and the SMSmessage application can read the verification code in the SMS message,and another application cannot read the verification code, so thatleakage of information about an SMS message of a user can be prevented.In a mobile payment or verification field, a risk faced by mobilepayment or verification can also be reduced, to ensure security of themobile payment or verification.

With reference to the third aspect, in a first possible implementationof the third aspect, the processor is further configured to fill averification code input area with the read verification code. A troublethat the user needs to first remember the verification code and thenmanually enter the verification code can be avoided, thereby improvinguser experience.

With reference to the third aspect, in a second possible implementationof the third aspect, the processor is further configured to display theread verification code in a display area of the input method applicationon the terminal. A trouble that the user opens the SMS messageapplication to view the verification code can be avoided. Then, the userfills in a verification code input box with the verification code basedon the verification code displayed in the area of the input methodapplication. In comparison with a solution of automatically filling in averification code, this solution in which the verification code is firstdisplayed in the area of the input method application and then the usermanually enters the verification code can ensure accuracy of enteringthe verification code.

With reference to the third aspect, in a third possible implementationof the third aspect, the processor is further configured to displaycharacters in a character string one by one on a keyboard of the inputmethod application in a sequence of the characters in the characterstring included in the read verification code. The user is reminded of ato-be-entered verification code in a more intuitive manner in thissolution.

In a possible implementation, the characters in the character string aredisplayed one by one in an animation manner on the input methodapplication. The animation manner includes changing a size, a shape, acolor, a border, a shade, or the like of a corresponding character in anarea of the input method application.

With reference to any one of the third aspect to the third possibleimplementation of the third aspect, in a fourth possible implementationof the third aspect, the transceiver is specifically configured toreceive, within a preset time, at least two SMS messages that include averification code and that are sent by the server; and the processor isfurther configured to: determine all SMS messages that include averification code and that are received within the preset time;determine an SMS message that includes an application identifier in allthe SMS messages that include a verification code, where the applicationidentifier is used to identify the application that is to obtain averification code; and read a verification code in the SMS message thatincludes the application identifier. When the user receives a pluralityof verification codes within a specific time, a verification codemeeting a condition can be automatically screened, so that a troublethat the user performs manual screening is avoided.

With reference to the fourth possible implementation of the thirdaspect, in a fifth possible implementation of the third aspect, theprocessor is further specifically configured to: if it is determinedthat there are at least two SMS messages that include the applicationidentifier in all the SMS messages that include a verification code,determine an SMS message that is received at a latest time in the SMSmessages that include the application identifier; and read averification code in the SMS message received at the latest time. Thetrouble that the user manually selects the verification code meeting thecondition can be avoided.

According to a fourth aspect, a computer readable storage medium storingone or more programs is provided, where the one or more programs includean instruction, a portable electronic device including a display and aplurality of applications performs the method according to any one ofthe first aspect to the fifth possible implementation of the firstaspect when the instruction is executed by the portable electronicdevice, and the display is configured to display an application runningon the portable electronic device.

According to a fifth aspect, a verification code obtaining method isprovided, and the method includes: sending, by an application that is toobtain a verification code, a verification code obtaining request to aserver, where the application that is to obtain a verification code runson an operating system; based on a received SMS message that includes averification code and that is sent by the server, reading, by theoperating system, the verification code in the SMS message, and sendingthe read verification code to a clipboard of the operating system; andreceiving, by the operating system, a pasting instruction, and pastingthe verification code on the clipboard in a verification code inputarea. In this solution, the operating system directly reads theverification code onto the clipboard without a need to consider whetherto provide another application program with SMS message read permission,so that it can be convenient for a user to enter the verification code,and it can be ensured that user SMS message privacy is not leaked.

According to a sixth aspect, a terminal is provided, including aprocessor, a memory, and a transceiver, where the memory is configuredto store an application that is to obtain a verification code; thetransceiver is configured to send a verification code obtaining requestto a server; the transceiver is further configured to receive an SMSmessage that includes a verification code and that is sent by theserver; the processor is configured to: read the verification code inthe SMS message, and send the read verification code to a clipboard ofthe operating system; and the processor is further configured to pastethe verification code on the clipboard in a verification code input areabased on a pasting instruction. In this solution, the processor directlyreads the verification code onto the clipboard without a need toconsider whether to provide another application program with SMS messageread permission, so that it can be convenient for a user to enter theverification code, and it can be ensured that user SMS message privacyis not leaked.

In a possible implementation, before the application that is to obtain averification code sends the verification code obtaining request to theserver, the method further includes: receiving a verification codeobtaining operation triggered by a user. The verification code obtainingoperation is triggered by the user, so that the application can beprevented from randomly sending verification code information.

In a possible implementation, the operating system includes an Androidoperating system, an iOS operating system, and a Windows Phone operatingsystem.

In a possible implementation, the input method application and the SMSmessage application are applications developed by a developer of theoperating system running on the terminal. In this case, the input methodapplication and the SMS message application are default applications ofthe operating system, and are more secure than a third-partyapplication.

In a possible implementation, the input method application and the SMSmessage application are applications developed by a third-partyapplication developer, and the third-party application developer is anapplication developer other than a developer of the operating systemrunning on the terminal.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in the embodiments of the presentinvention more clearly, the following briefly describes the accompanyingdrawings required for describing the embodiments. Apparently, theaccompanying drawings in the following description show merely someembodiments of the present invention, and persons of ordinary skill inthe art may still derive other drawings from these accompanying drawingswithout creative efforts.

FIG. 1A is an example diagram of a verification code obtaining method;

FIG. 1B is an example diagram of another verification code obtainingmethod;

FIG. 1C is an example diagram of still another verification codeobtaining method;

FIG. 2A is an example diagram of displaying a verification codeaccording to an embodiment of the present invention;

FIG. 2B is another example diagram of displaying a verification codeaccording to an embodiment of the present invention;

FIG. 3A is still another example diagram of displaying a verificationcode according to an embodiment of the present invention;

FIG. 3B is another example diagram of displaying a verification codeaccording to an embodiment of the present invention;

FIG. 3C is still another example diagram of displaying a verificationcode according to an embodiment of the present invention; and

FIG. 3D is another example diagram of displaying a verification codeaccording to an embodiment of the present invention.

DESCRIPTION OF EMBODIMENTS

To make the objectives, technical solutions, and advantages of theembodiments of the present invention clearer, the following clearlydescribes the technical solutions in the embodiments of the presentinvention with reference to the accompanying drawings in the embodimentsof the present invention. Apparently, the described embodiments are somerather than all of the embodiments of the present invention. All otherembodiments obtained by persons of ordinary skill in the art based onthe embodiments of the present invention without creative efforts shallfall within the protection scope of the present invention.

Ordinal numbers such as “first” and “second” mentioned in theembodiments of the present invention shall only serve the purpose ofdifferentiation unless the numbers definitely indicate a sequence basedon the context.

Currently, an operating system commonly used on a terminal includes anAndroid operating system developed by Google, an iOS operating systemdeveloped by Apple, and a Windows Phone operating system developed byMicrosoft.

In an example in which the Android (Android) system is used, anapplication may read all SMS messages in the system by applying for SMSmessage read permission, and obtain a verification code from the SMSmessage. A main function of most applications other than an SMS messageapplication that apply for SMS message permission is to read an SMSmessage verification code. As shown in FIG. 1A, a user uses anapplication for shopping. For transaction security, the applicationprompts that the user needs to fill in a check code. After a terminalreceives an SMS message including a check code, the user may manuallyfill in a “payment check code” input box in FIG. 1A with the check codein the SMS message. If the application has applied for SMS message readpermission, the application may extract the check code in the SMSmessage, and automatically fill in the “payment check code” input box inFIG. 1A with the extracted check code. For another example, as shown inFIG. 1B and FIG. 1C, when a user logs in to WeChat(WeChat), for accountsecurity of the user, the user is required to enter a verification code.After the user receives a verification code SMS message from “TencentTechnology”, the user may manually enter a verification code “240960” inthe SMS message into a “Fill in a verification code” input box in FIG.1C. If WeChat has applied for SMS message read permission, WeChat mayextract the verification code in the SMS message, and automatically fillin the “Fill in a verification code” input box in FIG. 1C with theverification code “240960” in the SMS message.

To automatically extract a verification code in an SMS message andautomatically enter the extracted verification code into a verificationcode input box, an application (such as WeChat) first needs to apply forpermission to read an SMS message in a system. After the system receivesan SMS message, the system sends a broadcast that the SMS message isreceived. After receiving the broadcast, WeChat reads content of the SMSmessage, and extracts a verification code from the SMS message. However,the SMS message read permission of WeChat is permission to read all SMSmessages in the system. WeChat can read not only a verification code SMSmessage required by WeChat, but also an SMS message that is received andsent by a user when the user normally uses an SMS message application.In addition, WeChat can read an SMS message verification code of anotherapplication. This causes a service such as mobile payment on a mobileterminal to face a risk, and also easily causes user privacy leakage.

Embodiment 1

Embodiment 1 provides a verification code obtaining method. The methodincludes the following steps.

101. An application that is to obtain a verification code sends averification code obtaining request to a server, where the applicationthat is to obtain a verification code is installed on a terminal, andapplications installed on the terminal further include an input methodapplication and an SMS message application.

The application that is to obtain a verification code is an applicationinstalled on the terminal. For example, the application may be WeChat,Alipay (Alipay), or the like. An operating system running on theterminal may be an Android operating system, an iOS operating system,and a Windows Phone operating system.

Applications installed on the terminal by default usually include theinput method application and the SMS message application. In anotherembodiment, the input method application and the SMS message applicationare applications developed by a developer of the operating systemrunning on the terminal. In still another embodiment, the input methodapplication and the SMS message application are applications developedby a third-party application developer, and the third-party applicationdeveloper is an application developer other than a developer of theoperating system running on the terminal. For example, a developer ofAndroid is Google. In this case, a default input method in a nativeAndroid system is a Google input method. The Google input method is anapplication developed by the developer of the Android system. A Sogouinput method or a Swype input method is an application developed by athird-party application developer.

Similarly, a default Android 5.0 SMS message application is Messenger,which is an SMS message application developed by Google. An SMS messageapplication Textra or GoSMS is an application developed by a third-partyapplication developer. In Android systems of some versions, Hangouts(Hangout) may be used to display an SMS message in the terminal, andtherefore Hangouts also belongs to an SMS message application. Usually,all SMS message applications may be used to manage and display an SMSmessage in the terminal.

For another example, in relative to the Android system, Google map is anapplication developed by the Android system developer Google, and isreferred to as a native Android application. In relative to an iOSsystem of Apple, Google map belongs to an application developed by athird-party developer, and Google map is not a native iOS application.

The server is a server corresponding to the application that is toobtain a verification code. For example, a server corresponding toWeChat may be a server of Tencent, or may be a leased server. This isnot limited in the present invention.

102. The SMS message application receives an SMS message that includes averification code and that is sent by the server.

The SMS message application may receive and send an SMS message, and mayspecifically receive and send the SMS message by using a transceiver.

A possible form of the SMS message is as follows:

SMS message example 1: (2665) Didi Chuxing verification code [DidiChuxing] “2665” is a verification code required by a Didi Chuxing APP.

SMS message example 2: Verification code: 236820. Please do not forward.A 12306 user is applying for a password modification service. If you didnot perform this operation, please ignore this message. [RailwayCustomer Service] “236820” is a verification code required by a Railway12306 APP.

SMS message example 3: [G.CN] Your Google verification code is 989345.

“989345” is a verification code required by a Google service.

103. The input method application reads the verification code in the SMSmessage, where the terminal does not allow an application other than theinput method application and the SMS message application to read an SMSmessage in the terminal.

To ensure user information security, the terminal allows only the inputmethod application and the SMS message application to read the SMSmessage. In most cases, a terminal has an input method application andan SMS message application. The input method application is used toenter information, for example, by using typewriting, handwriting, orvoice input. The SMS message application is used to display an SMSmessage in the terminal. An input method application and an SMS messageapplication are installed by default regardless of an Android system, aniOS system, or a Windows Phone system.

If a user installs a third-party input method application or athird-party SMS message application, and trusts the third-party inputmethod application or the third-party SMS message application, the usermay allow, to read the SMS message in the terminal, the input methodapplication or the SMS message application developed by a third-partydeveloper. For example, the user allows the Sogou input method to readthe SMS message in the terminal. The permission to allow an applicationto read the SMS message may be that a system provides an applicationwith SMS message read permission by default; or may be that a promptpops up, so that the user chooses whether to provide an application withSMS message read permission. For example, the user installs the Sogouinput method that is a third-party input method. If the Sogou inputmethod requests SMS message read permission, a prompt pops up in thesystem, so that the user chooses whether to provide the Sogou inputmethod with the SMS message read permission. Alternatively, the userinstalls the Sogou input method that is a third-party input method.Regardless of whether the Sogou input method applies for SMS messageread permission, when the system detects that the user installs theinput method application, a prompt pops up, so that the user chooseswhether to provide the newly installed input method with the SMS messageread permission. An implementation in which the SMS message applicationrequests the SMS message read permission is similar to that of the inputmethod application.

In an embodiment, after the input method application reads theverification code in the SMS message, the method further includes:filling a verification code input area with the read verification code.

“Payment check code” in FIG. 1A is a verification code input area ofWeChat. The input area may be an input box. For convenience of the user,the terminal may directly extract the verification code in the SMSmessage through semantic analysis, and automatically fill in theverification code input area with the extracted verification code, sothat a trouble that the user needs to first remember the verificationcode and then manually enter the verification code can be avoided,thereby improving user experience.

In another embodiment, after the input method application reads theverification code in the SMS message, the method further includes:displaying the read verification code in a display area of the inputmethod application on the terminal. As shown in FIG. 2A or FIG. 2B, aninput method is a Baidu input method, and the application that is toobtain a verification code is a WeChat application. WeChat sends averification code obtaining request to the server. Then, the terminalreceives an SMS message that includes a verification code and that issent by the server. The Baidu input method reads the verification codein the SMS message, and displays the verification code (2460) in adisplay area of the Baidu input method on a user interface (UserInterface, UI for short) of the terminal. As shown in FIG. 2A, theverification code (2460) may be displayed in the display area of theinput method. Alternatively, as shown in FIG. 2B, the verification code(2460) may be displayed in an extended area of the input method on theUI.

The user performs an operation on the verification code 2460. Based onthe operation of the user, the system automatically fills in, with 2460,the verification code input area, namely, a “Fill in a verificationcode” area shown in FIG. 2A. A manner in which the user performs anoperation on the verification code displayed in the area of the inputmethod includes: tap, double tap, touch and hold, press heavily, pressgently, float, and the like. In addition, the operation herein may bereplaced with voice, and is not necessarily a direct tap on a key of aninput method keyboard. Alternatively, the operation is implemented byusing eye tracking. To be specific, the user gazes at a button by usingan eye, and when detecting motion of the eye of the user, the terminalautomatically fills in the verification code input area with theverification code. In an embodiment, a prompt box “Tap to fill in averification code” or a similar prompt statement pops up around theverification code, to facilitate the user operation.

In this way, a trouble that the user opens the SMS message applicationto view the verification code can be avoided. Then, the user fills in averification code input box with the verification code based on theverification code displayed in the area of the input method application.In comparison with a solution of automatically filling in a verificationcode, this solution in which the verification code is first displayed inthe area of the input method application and then the user manuallyenters the verification code can ensure accuracy of entering theverification code.

In another embodiment, after the input method application reads theverification code in the SMS message, the method further includes:displaying characters in a character string one by one on a keyboard ofthe input method application in a sequence of the characters in thecharacter string included in the read verification code.

Referring to the SMS message examples 1 to 3, the character string maybe a number string, and a quantity of digits in the number string mayvary with different applications. Alternatively, the character stringmay be a letter string. For example, the verification code may be“nyNb”. Alternatively, the character string may be a character string ofa combination of numbers and letters. For example, the verification codemay be “594 nB”.

In an embodiment, the characters in the character string are displayedone by one in an animation manner on an input method keyboard. Theanimation manner includes changing a size, a shape, a color, a border, ashade, or the like of a corresponding character in an area of the inputmethod keyboard.

As shown in FIG. 3A to FIG. 3D, the following provides a description byusing an example in which the verification code is a number string 2460.

The animation manner may be adding, on the input method keyboard forprompting, a circular border to a character corresponding to theverification code. As shown in FIG. 3A, a first character of theverification code is a number 2. In this case, a circular border isadded to the number 2 at a location of the number 2 on the input methodkeyboard. Animation manners of the other numbers are similar to theanimation manner. To improve user experience, a “character sequenceprompt” may be further added around the number 2. For example, thenumber 2 is the first character of the verification code 2460. In thiscase, a badge {circle around (1)} is added around the number 2 when ashape of the number 2 on the keyboard is changed, to prompt the userthat this is the first character of the verification code that needs tobe entered. As shown in FIG. 3B, after the user completes entering, thenumber 2 restores to an original state, and the badge {circle around(1)} is no longer displayed.

Similarly, as shown in FIG. 3B, the first character of the verificationcode is a number 4. After the number 2 restores to the original state,and the badge {circle around (1)} is no longer displayed, a circularborder is added to the number 4 on the input method keyboard, and aprompt badge {circle around (2)} is displayed around the number 4, toprompt the user that this is the second character of the verificationcode that needs to be entered. As shown in FIG. 3C, after the usercompletes entering, the number 4 restores to an original state, and thebadge {circle around (2)} is no longer displayed.

A prompt manner of a third character 6 and a fourth character 0 of theverification code is similar to that in the foregoing solution.

The manner of prompting verification code entering is more intuitive,thereby improving user experience.

In another embodiment, the SMS message application receives, within apreset time, at least two SMS messages that include a verification codeand that are sent by the server. All SMS messages that include averification code and that are received within the preset time aredetermined. An SMS message that includes an application identifier inall the SMS messages that include a verification code is determined. Theapplication identifier is used to identify the application that is toobtain a verification code. The input method application reads averification code in the SMS message that includes the applicationidentifier.

In an example in which payment is performed on a Railway 12306 APPclient on a mobile phone, at least two SMS messages that include averification code and that are sent by the server are received within apreset time, and the method includes the following steps.

201. Determine all SMS messages that include a verification code andthat are received within the preset time.

The preset time may be 2 minutes. For example, two SMS messages arereceived within 2 minutes. One is sent by Railway 12306, and the otheris sent by Google. Content of the SMS messages is described in the “SMSmessage example 2” and the “SMS message example 3”.

202. Determine an SMS message that includes an application identifier inall the SMS messages that include a verification code, where theapplication identifier is used to identify the application that is toobtain a verification code.

The SMS message that includes a verification code and that is sent bythe Railway 12306 application usually includes an application identifier“[Railway Customer Service]”. The application identifier is used toidentify that the SMS message is sent by a Railway 12306 server.“[Railway Customer Service]” or “Railway Customer Service” may be theapplication identifier of the Railway 12306 application. Alternatively,the application identifier may be a string of characters, such as Alipayor WeChat.

203. The input method application reads a verification code in the SMSmessage that includes the application identifier.

The input method application reads the verification code 23680 in theSMS message example 2.

In another embodiment, if it is determined that there are at least twoSMS messages that include the application identifier in all the SMSmessages that include a verification code, an SMS message that isreceived at a latest time in the SMS messages that include theapplication identifier is determined. The input method application readsa verification code in the SMS message received at the latest time.

In the example in which payment is performed on the Railway 12306 APPclient on the mobile phone, if it is determined that there are at leasttwo SMS messages that include the application identifier in all the SMSmessages that include a verification code, the method includes thefollowing steps.

301 is the same as step 201.

302. If it is determined that there are at least two SMS messages thatinclude the application identifier in all the SMS messages that includea verification code, determine an SMS message that is received at alatest time in the SMS messages that include the application identifier,where the application identifier is used to identify the applicationthat is to obtain a verification code.

For example, three SMS messages are received within 2 minutes. One issent by Google, and content of the SMS message is described in the SMSmessage example 3. One is sent by Railway 12306, content of the SMSmessage is described in the SMS message example 2, and a receiving timeis “17:21:23 Oct. 9, 2015”. One is sent by Railway 12306, and content ofthe SMS message is as follows:

SMS message example 4: Verification code: 223366. Please do not forward.A 12306 user is applying for a password modification service. If you didnot perform this operation, please ignore this message. [RailwayCustomer Service]

A receiving time of the SMS message example 4 is “17:22:42 Oct. 9,2015”.

The receiving time of the SMS message example 4 is later. Therefore, itis determined that the SMS message example 4 is a verification code SMSmessage required by the Railway 12306 APP.

303. The input method application reads a verification code in the SMSmessage received at the latest time.

The input method reads the verification code 223366 in the SMS messageexample 4.

In the verification code obtaining method provided in this embodiment ofthe present invention, because only the input method application and theSMS message application are provided with the permission to read the SMSmessage in the terminal, leakage of information about the SMS message ofthe user can be prevented, and security of verification code informationin the SMS message can be ensured.

Embodiment 2

Embodiment 2 provides a verification code obtaining method. The methodincludes the following steps.

401. An application that is to obtain a verification code sends averification code obtaining request to a server, where the applicationthat is to obtain a verification code runs on an operating system.

The application that is to obtain a verification code runs on theoperating system. For example, the application may be WeChat, Alipay(Alipay), or the like. The operating system may be an Android operatingsystem, an iOS operating system, and a Windows Phone operating system.

402. Based on a received SMS message that includes a verification codeand that is sent by the server, the operating system reads theverification code in the SMS message, and sends the read verificationcode to a clipboard of the operating system.

A possible form of the SMS message is the same as that described in step102.

In an example in which an Android system is used, a clipboard(clipboard) of the Android system is managed by a classClipboardManager. The ClipboardManager represents the clipboard of thesystem, and is obtained by using getSystemService (CLIPBOARD SERVICE).An invoking manner is android.content.ClipboardManager (since API Level11).

An iOS system also has a clipboard.

403. The operating system receives a pasting instruction, and pastes theverification code on the clipboard in a verification code input area.

The pasting instruction may be a pasting instruction triggered by a userby tapping or touching and holding an input box, or may be a pastinginstruction automatically triggered by the operating system whendetecting that there is a verification code on the clipboard.

In this manner, the operating system directly reads the verificationcode onto the clipboard without a need to consider whether to provideanother application program with SMS message read permission, so that itcan be convenient for the user to enter the verification code, and itcan be ensured that user SMS message privacy is not leaked.

Embodiment 3

Embodiment 3 provides a verification code obtaining apparatus. Theapparatus is configured to perform the methods described in Embodiment 1and Embodiment 2.

In an embodiment, applications installed on the verification codeobtaining apparatus include an application that is to obtain averification code, an input method application, and an SMS messageapplication. The apparatus further includes: a sending unit, configuredto send a verification code obtaining request to a server; a receivingunit, configured to receive an SMS message that includes a verificationcode and that is sent by the server; and a reading unit, configured toread the verification code in the SMS message, where the apparatus doesnot allow an application other than the input method application and theSMS message application to read an SMS message in the apparatus.

In another embodiment, the apparatus further includes a filling unit,configured to fill a verification code input area with the readverification code.

In still another embodiment, the apparatus further includes a firstdisplay unit, configured to display the read verification code in adisplay area of the input method application on the apparatus.

In another embodiment, the apparatus further includes a second displayunit, configured to display characters in a character string one by oneon a keyboard of the input method application in a sequence of thecharacters in the character string included in the read verificationcode.

In still another embodiment, the receiving unit is specificallyconfigured to receive, within a preset time, at least two SMS messagesthat include a verification code and that are sent by the server.

The apparatus further includes: a first determining unit, configured todetermine all SMS messages that include a verification code and that arereceived within the preset time; and a second determining unit,configured to determine an SMS message that includes an applicationidentifier in all the SMS messages that include a verification code,where the application identifier is used to identify the applicationthat is to obtain a verification code.

The reading unit is specifically configured to read a verification codein the SMS message that includes the application identifier.

In another embodiment, the second determining unit is specificallyconfigured to: if it is determined that there are at least two SMSmessages that include the application identifier in all the SMS messagesthat include a verification code, determine an SMS message that isreceived at a latest time in the SMS messages that include theapplication identifier; and the reading unit is specifically configuredto read a verification code in the SMS message received at the latesttime.

According to the apparatus provided in this embodiment of the presentinvention, leakage of information about an SMS message of a user can beprevented, and security of verification code information in the SMSmessage can be ensured.

Embodiment 4

Embodiment 4 provides a terminal, and the terminal is configured toperform the method described in Embodiment 1.

In an embodiment, the terminal includes a processor, a memory, and atransceiver.

The memory is configured to store applications. The applications areinstalled on the terminal, the applications stored in the memory includean application that is to obtain a verification code, an input methodapplication, and an SMS message application, and the SMS messageapplication is used to display an SMS message in the terminal.

The transceiver is configured to send a verification code obtainingrequest to a server.

The transceiver is further configured to receive an SMS message thatincludes a verification code and that is sent by the server.

The processor is configured to read the verification code in the SMSmessage. The terminal does not allow an application other than the inputmethod application and the SMS message application to read an SMSmessage in the terminal.

In another embodiment, the processor is further configured to fill averification code input area with the read verification code.

In still another embodiment, the processor is further configured todisplay the read verification code in a display area of the input methodapplication on the terminal.

In another embodiment, the processor is further configured to displaycharacters in a character string one by one on a keyboard of the inputmethod application in a sequence of the characters in the characterstring included in the read verification code.

In still another embodiment, the transceiver is specifically configuredto receive, within a preset time, at least two SMS messages that includea verification code and that are sent by the server.

The processor is further configured to: determine all SMS messages thatinclude a verification code and that are received within the presettime; determine an SMS message that includes an application identifierin all the SMS messages that include a verification code, where theapplication identifier is used to identify the application that is toobtain a verification code; and read a verification code in the SMSmessage that includes the application identifier.

In another embodiment, the processor is further specifically configuredto: if it is determined that there are at least two SMS messages thatinclude the application identifier in all the SMS messages that includea verification code, determine an SMS message that is received at alatest time in the SMS messages that include the application identifier;and read a verification code in the SMS message received at the latesttime.

According to the terminal provided in this embodiment of the presentinvention, leakage of information about an SMS message of a user can beprevented, and security of verification code information in the SMSmessage can be ensured.

An embodiment of the present invention further provides a terminal, andthe terminal is configured to perform the method described in Embodiment2.

The terminal includes a processor, a memory, and a transceiver.

The memory is configured to store an application that is to obtain averification code.

The transceiver is configured to send a verification code obtainingrequest to a server.

The transceiver is further configured to receive an SMS message thatincludes a verification code and that is sent by the server.

The processor is configured to: read the verification code in the SMSmessage, and send the read verification code to a clipboard of theoperating system.

The processor is further configured to paste the verification code onthe clipboard in a verification code input area based on a pastinginstruction.

According to the terminal provided in this embodiment of the presentinvention, in this solution, the processor directly reads theverification code onto the clipboard without a need to consider whetherto provide another application program with SMS message read permission,so that it can be convenient for a user to enter the verification code,and it can be ensured that user SMS message privacy is not leaked.

Embodiment 5

Embodiment 5 provides a computer readable storage medium storing one ormore programs, where the one or more programs include an instruction, aportable electronic device including a display and a plurality ofapplications performs the method described in Embodiment 1 and/or themethod described in Embodiment 2 when the instruction is executed by theportable electronic device, and the display is configured to display anapplication running on the portable electronic device.

Finally, it should be noted that the foregoing embodiments are merelyintended for describing examples of the technical solutions of thepresent invention other than limiting the present invention. Althoughthe present invention and benefits of the present invention aredescribed in detail with reference to the foregoing embodiments, personsof ordinary skill in the art should understand that they may still makemodifications to the technical solutions described in the foregoingembodiments or make equivalent replacements to some technical featuresthereof, without departing from the scope of the claims of the presentinvention.

What is claimed is:
 1. An electronic device having an operating system,comprising: a processor; a memory coupled to the processor and storingprogram instructions which, when executed by the processor, cause theelectronic device to: display a first user interface of a firstapplication and a second user interface of a third-party input methodapplication, wherein the third-party input method application has afirst keyboard, wherein the first user interface comprises an inputarea, wherein the second user interface of the third-party input methodapplication is displayed below the first user interface of the firstapplication, wherein the electronic device comprises a plurality ofapplications, wherein the plurality of applications includes the firstapplication, a short message service (SMS) application, and a defaultinput method application having a second keyboard, and wherein the SMSapplication and the default input method application are provided by adeveloper of the operation system; receive, by the SMS application, afirst SMS message comprising a first verification code; automaticallydisplay the first user interface of the first application and the firstverification code above the second keyboard of the default input methodapplication instead of displaying the first verification code above thefirst keyboard of the third-party input method application; receive atap operation on the first verification code; and fill, in response tothe tap operation, the first verification code to the input area.
 2. Theelectronic device of claim 1, wherein the instructions further cause theelectronic device to display the first verification code above a digitalkeyboard area of the default input method application.
 3. The electronicdevice of claim 2, wherein the first application is developed by athird-party.
 4. The electronic device of claim 3, wherein the firstverification code is 4 digits or 6 digits.
 5. The electronic device ofclaim 4, wherein the instructions further cause the electronic device tonot allow the third-party input method application to read the firstverification code.
 6. The electronic device of claim 4, wherein theinstructions further cause the electronic device to: receive a secondSMS message comprising a second verification code, wherein the secondSMS message is received later than the first SMS message; automaticallydisplay the second verification code above the second keyboard; receivea second tap operation on the second verification code; and fill, inresponse to the second tap operation, the second verification code tothe input area.
 7. The electronic device of claim 1, wherein theinstructions further cause the electronic device to only allow thedefault input method application and the SMS application to read thefirst verification code.
 8. The electronic device of claim 1, whereinthe first SMS message comprises an identifier indicating the firstapplication.
 9. The electronic device of claim 8, wherein theinstructions further cause the electronic device to read the firstverification code by the identifier after the first SMS message isreceived and before the first verification code is automaticallydisplayed.
 10. A method implemented by an electronic device, the methodcomprising: displaying a first user interface of a first application anda second user interface of a third-party input method application,wherein the third-party input method application has a first keyboard,wherein the first user interface of the first application comprises aninput area, wherein the second user interface of the third-party inputmethod application is displayed below the first user interface of thefirst application, wherein the electronic device comprises a pluralityof applications, wherein the plurality of applications includes thefirst application, a short message service (SMS) application, and adefault input method application having a second keyboard, and whereinthe SMS application and the default input method application areprovided by a developer of an operation system installed in theelectronic device; receiving, by the SMS application, a first SMSmessage comprising a first verification code; automatically displayingthe first user interface of the first application and the firstverification code above the second keyboard of the default input methodapplication instead of displaying the first verification code above thefirst keyboard of the third-party input method application; receiving afirst operation on the first verification code; and filling, in responseto the first operation, the first verification code to the input area.11. The method of claim 10, further comprising displaying the firstverification code above a digital keyboard area of the default inputmethod application.
 12. The method of claim 11, wherein the firstapplication is developed by a third-party.
 13. The method of claim 12,wherein the first verification code is 4 digits or 6 digits.
 14. Themethod of claim 10, further comprising not allowing the third-partyinput method application to read the first verification code.
 15. Themethod of claim 10, further comprising: receiving a second SMS messagecomprising a second verification code, wherein the second SMS message isreceived later than the first SMS message; automatically displaying thesecond verification code above the second keyboard of the default inputmethod application; receiving a second operation on the secondverification code; and filling, in response to the second operation, thesecond verification code to the input area.
 16. The method of claim 15,wherein the first operation comprises a first tap, a first double tap, afirst touch and hold, a first heavy press, a first gentle press, a firstfloat, or first eye tracking, and wherein the second operation comprisesa second tap, a second double tap, a second touch and hold, a secondheavy press, a second gentle press, a second float, or second eyetracking.
 17. The method of claim 10, further comprising only allowingthe default input method application and the SMS application to read thefirst verification code.
 18. The method of claim 10, wherein the firstSMS message comprises an identifier indicating the first application.19. The method of claim 18, further comprising reading the firstverification code after receiving the first SMS message and beforeautomatically displaying the first verification code.
 20. A computerprogram product comprising computer-executable instructions stored on anon-transitory computer-readable medium that, when executed by aprocessor, cause an electronic device to: display a first user interfaceof a first application and a second user interface of a third-partyinput method application, wherein the third-party input methodapplication has a first keyboard, wherein the first user interfacecomprises an input area, wherein the second user interface of thethird-party input method application is displayed below the first userinterface of the first application, wherein the electronic devicecomprises a plurality of applications, wherein the plurality ofapplications includes the first application, a short message service(SMS) application, and a default input method application having asecond keyboard, and wherein the SMS application and the default inputmethod application are provided by a developer of an operation system;receive, by the SMS application, a first SMS message comprising a firstverification code; automatically display the first user interface of thefirst application and the first verification code above the secondkeyboard of the default input method application instead of displayingthe first verification code above the first keyboard of the third-partyinput method application; receive a tap operation on the firstverification code; and fill, in response to the tap operation, the firstverification code to the input area.